<template>
  <div class="head_container" style="height: 60px">
    <div class="left fff">
      <div class="left_inner">
        <div class="flex one">
          <img
            style="width: 36px; height: 36px"
            src="../assets/head_imgs/head_logo.png"
            alt=""
          />
          <div>欣心</div>
        </div>
        <div class="flex two cur_poi">
          <div class="switch_btn" @click="handleSwitch">切换</div>
          <img
            style="width: 24px; height: 24px"
            src="../assets/hot_h.png"
            alt=""
          />
          <div>0</div>
        </div>
      </div>
    </div>
    <div class="midd"></div>
    <div class="right flex cur_poi">
      <div class="info flex">
        <div class="avatar bd_radio">
          <img
            class="bd_radio"
            style="width: 40px; height: 40px"
            :src="store.loginer?.user?.headimgurl"
            alt=""
          />
        </div>
        <div class="nickName fs_14 fff">{{ store.loginer?.user?.nickname }}</div>
      </div>
      <img
        @click="handleIcon(1)"
        class="cur_poi"
        src="../assets/arr_down.png"
        alt=""
      />
      <img
        @click="handleIcon(2)"
        class="cur_poi"
        src="../assets/head_imgs/head_msg.png"
        alt=""
      />

      <img
        @click="handleIcon(3)"
        class="cur_poi"
        src="../assets/head_imgs/head_serv.png"
        alt=""
      />

      <img
        @click="handleIcon(4)"
        class="cur_poi"
        src="../assets/head_imgs/head_reduce.png"
        alt=""
      />

      <img
        v-if="isZoom"
        @click="handleIcon(5)"
        class="cur_poi"
        src="../assets/head_imgs/head_zoom_big.png"
        alt=""
      />
      <img
        v-else
        @click="handleIcon(6)"
        class="cur_poi"
        src="../assets/head_imgs/head_zoom_small.png"
        alt=""
      />
      <img
        @click="handleIcon(7)"
        class="cur_poi"
        src="../assets/head_imgs/head_close.png"
        alt=""
      />
      <!-- </div> -->
    </div>
    <div class="rooms_box" v-if="isShow">
      <div class="txt_cent fff title">请选择公会房间</div>
      <div class="body">
        <div
          class="out cur_poi flex"
          @click="linkToChannel(item)"
          v-for="(item, i) in roomList"
          :key="i"
        >
          <div class="item_content flex_row">
            <div class="avatar">
              <img :src="item.img" alt="" />
              <!-- <img
                src="../../public/logo.jpg"
                alt=""
              /> -->
            </div>
            <div class="info flex_colm bs_bdb fff">
              <div class="fs_12">{{ item.nickname || "" }}</div>
              <div class="fs_12">{{ item.id || "" }}</div>
            </div>
          </div>
          <div class="fff fs_12">选择</div>
        </div>
      </div>
    </div>
    <!-- 消息组件 -->
    <newsCpts v-show="true"/>
  </div>
</template>

<script setup>
import { onMounted, ref } from "vue";
import newsCpts from "./newsCpts.vue";
import img from "../utils";
import { useCounterStore } from "../store";
import { getRooms, getTokenByRoomId } from "../http";
const store = useCounterStore();
const { ipcRenderer } = require("electron");
const isShow = ref(false);
const isZoom = ref(true);
const roomList = ref([]);

const handleIcon = (val) => {
  // 测试缩小窗口
  if (Number(val) === 6) {
    ipcRenderer.send("windows_setmaximize");
    isZoom.value = true;
  }
  if (Number(val) === 7) {
    ipcRenderer.send("windows_close");
  }
  if (Number(val) === 5) {
    ipcRenderer.send("windows_fullscreen");
    isZoom.value = false;
  }
  if (Number(val) === 4) {
    ipcRenderer.send("windows_minimize");
  }
  if (Number(val) === 2) {
  }
};
const handleSwitch = () => {
  isShow.value = !isShow.value;
};

const linkToChannel = async (e) => {
  let res = await getTokenByRoomId(store.loginer?.jwt, e.id);
  if (res.data.errcode === 0) {
    console.log("直播的对象:", res.data);
  }
};
onMounted(() => {
  getRooms(store.loginer?.jwt).then((res) => {
    if (res.data.errcode === 0) {
      roomList.value = res.data.list;
    }
  });
});

const iconList = [
  { url: "../assets/arr_down.png", id: "1" },
  { url: "../assets/head_imgs/head_msg.png", id: "2" },
  { url: "../assets/head_imgs/head_serv.png", id: "3" },
  { url: "../assets/head_imgs/head_reduce.png", id: "4" },
  { url: "../assets/head_imgs/head_zoom_big.png", id: "5" },
  { url: "../assets/head_imgs/head_close.png", id: "6" },
];
</script>

<style scoped lang="scss">
.flex {
  display: flex;
  align-items: center;
  justify-content: center;
}
.head_container {
  .rooms_box {
    position: absolute;
    left: 26px;
    top: 61px;
    width: 331px;
    padding: 5px;
    box-sizing: border-box;
    height: 355px;
    background: #282c2f;
    border-radius: 0px 0px 0px 0px;
    // border: 1px solid red;
    // .item {
    // width: 322px;
    // height: 50px;
    .title {
      margin: 19px 0 24px 0;
    }
    .body {
      padding: 5px 8px;
      box-sizing: border-box;
      height: calc(100% - 64px);
      overflow-y: auto;
    }
    .out {
      background: #51585d;
      border-radius: 10px 10px 10px 10px;
      margin-bottom: 10px;
      padding: 5px;
      box-sizing: border-box;
    }
    .item_content {
      flex: 1;
      overflow-y: auto;
      box-sizing: border-box;
      .avatar {
        width: 38px;
        height: 38px;
        background: #ffffff;
        border-radius: 50%;
        img {
          width: 100%;
          height: 100%;
          border-radius: 50%;
        }
      }
      .info {
        padding: 5px;
        .icons_sort {
          margin-top: 6px;
        }
      }
    }

    // }
  }
  background: #1d1f22;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15rpx;
  box-sizing: border-box;
  .right {
    // padding: 15px 10px;
    // box-sizing: border-box;

    .info {
      .nickName{
        margin:0 20px 0 5px;

      }
    }
    img {
      width: 24px;
      height: 24px;
      margin: 0 10px;
    }
    //     img:hover{
    //  background: #8f8989;
    //     }
    img:not(:last-child) {
      // margin-right: 10px;
    }
  }

  .left {
    .left_inner {
      // width: 280px;
      width: 280px;
      display: flex;
      justify-content: space-between;
      padding: 13px 12px;
      box-sizing: border-box;
      // justify-content: space-between;
      img {
        width: 36px;
        height: 36px;
        margin-right: 16px;
      }
      .two {
        .switch_btn {
          font-size: 16px;
          color: #ffffff;
          text-align: center;
          // width: 48px;
          padding: 6px 11px;
          box-sizing: border-box;
          // height: 28px;
          background: linear-gradient(90deg, #ff21ce 0%, #ff3166 100%);
          border-radius: 50px 50px 50px 50px;
          margin-right: 6px;
        }
      }
    }
  }
  .midd {
    flex: 1;
    height: 60px;
    cursor: move; /* 鼠标悬停时显示为移动手势 */
    -webkit-app-region: drag; /* 允许拖动的区域 */
  }
}

/* 自定义整个滚动条 */
::-webkit-scrollbar {
  width: 5px; /* 设置滚动条的宽度 */
}

/* 自定义滚动条轨道 */
::-webkit-scrollbar-track {
  background: #f1f1f1; /* 设置轨道的背景颜色 */
}

/* 自定义滚动条的滑块（thumb） */
::-webkit-scrollbar-thumb {
  background: #888; /* 设置滑块的背景颜色 */
}

/* 当滑块悬停或活动时，可以添加更多样式 */
::-webkit-scrollbar-thumb:hover {
  background: #555; /* 设置滑块在悬停状态下的背景颜色 */
}
</style>
